Repository navigation
fix(render_gui): reject an odd count of width/height arguments - #200
Closed
harsh-thakkar7 wants to merge 2 commits into
Closed
harsh-thakkar7 wants to merge 2 commits into
harsh-thakkar7 wants to merge 2 commits into
Conversation
`render_gui.py shots 1440` — or any odd number of trailing arguments — silently built an empty viewport list: the range() pair loop drops the last size, so main() called shoot(out, []) and exited 0 after printing "[OK]" with zero screenshots. The web CI gate (web-syntax-check.yml) would then report a green render for a page nobody looked at. main() now refuses an odd argument count with a usage error (exit 2) before any rendering happens. Four tests in tests/test_render_gui_args.py cover the odd-count refusal, a trailing-size round trip, and the default viewport pair; five mutants of the guard are all killed.
main() only needs the browser stack when it actually renders, but the two playwright imports ran at import time, so the module could not be imported without the driver installed -- which the pytest job does not do. That made the argument validation (and its tests) unimportable in CI. The imports now live inside shoot(), where they are used.
Contributor
Author
|
Closing this one for now — happy to reopen or resubmit if it's still useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
python render_gui.py shots 1440— any odd count of trailing width/height arguments — silently produced zero screenshots and exited 0, printing[OK]as if the page had rendered fine.The arg loop
range(0, len(raw) - 1, 2)just drops the unpaired last value (or everything, when only one is given):Because
web-syntax-check.ymlrunsrender_gui.pyas a quality gate on every web change, a size list this tool silently misreads is a gate that can turn green without anyone having looked at a single viewport. A typo'd CI invocation would ship a visually broken GUI.Fix
main()now validates the argument count before doing anything: an odd count prints an explicitwidth×height pairserror to stderr and exits 2, so a malformed invocation can no longer masquerade as a passed render check.Tests
New
tests/test_render_gui_args.py(4 tests): odd counts (1 and 3 args) are refused with exit 2 andshoot()never runs; paired sizes pass through unchanged; no-arg runs still use the default viewports. The duff test fails onorigin/main(it returns 0 and shoots[]). Full suite 174 passed; ruff clean. Five mutants of the guard (removed check, inverted polarity, kept exit-0, wrong modulus, suppressed message) are all killed.Note
The two playwright imports now happen inside
shoot(), so the argument validation — and tests importingrender_gui— work in the pytest CI job, which does not install the browser driver.